package xgen;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

import java.io.PrintStream;

public class Enum {
    private final String name;
    private final String value;
    private String comment;

    public Enum(Element self) {
        name = self.getAttribute("name").trim();
        value = self.getAttribute("value").trim();
        Node c = self.getNextSibling();
        if (c != null && Node.TEXT_NODE == c.getNodeType()) {
            comment = c.getTextContent().trim().replaceAll("[\r\n]", "");
        }
    }

    public String getName() {
        return name;
    }

    public void print(PrintStream ps, String prefix) {
        ps.println(prefix + "public final static int " + name + " = " + value + "; // " + comment);
    }
}
